<template>
	<view class="background">
		<scroll-view scroll-y="true" style="height: 100%;">
			<view
				v-for="(order, orderIndex) in orderList"
				:key="orderIndex"
				class="order_item">
				<view class="order_info">
					<view class="order_info_item" style="padding-left: 24upx;">
						<!-- <view class="site_sign" style="background: #2697FF;"/> -->
						<!-- <text style="font-weight: 800; margin-left: 10upx;">{{order.stationOffName}}</text>
						<view class="site_sign" style="background: #2C2F33; width: 10upx; height: 10upx; margin-left: 10upx;"/> -->
						<text style="font-weight: 400;font-size: 36upx;">{{order.stationUpName}}</text>
						<image class="iconRouter" src="../../static/icon_router_target.png" />
						<text style="font-weight: 400;font-size: 36upx;">{{order.stationOffName}}</text>
						<!-- <view
							v-if="order.isCheck == 2"
							@click.stop="cancel(order.orderDetailId)"
							class="rder_item_btn" style="border-color: #FF8103; color: #FFFFFF;">
							<text>确认上车</text>
						</view> -->
						
					</view>
					<!-- <view class="order_info_item" style="justify-content: space-between;">
						<view class="order_info_item">
							<view class="site_sign" style="background: #FF603F;"/>
							<text style="font-weight: 400; margin-left: 10upx;">{{order.stationOffName}}</text>
						</view>
					</view> -->
					<view class="order_info_item" style="height: 50upx;">
						<view class="site_sign" style="background: #2697FF; opacity: 0;"/>
						<text 
							space="ensp"
							style="font-size: 34upx; color: #949699; margin-left: 10upx;">
							{{`乘车人: ${order.passengerName}  身份证：${order.idCard}`}}
						</text>
					</view>
					<view class="order_info_item" style="height: 50upx;">
						<view class="site_sign" style="background: #2697FF; opacity: 0;"/>
						<text 
							space="ensp"
							style="font-size: 34upx; color: #949699; margin-left: 10upx;">
							{{`联系电话: ${order.phone}`}}
						</text>
						<!-- <text style="line-height: 50upx; color: #1296db; margin-left: 40upx; font-size: 34rpx; font-weight: bold;">一键拨打</text> -->
					</view>
				</view>
				<view class="order_item_btn_warp">
					<view
						v-if="order.isCheck == 2"
						@click.stop="cancel(order.orderDetailId)"
						class="rder_item_btn" style="border-color: #FF8103; color: #FFFFFF;">
						<text>确认上车</text>
					</view>
					<view
						@tap="toTel(order.phone)"
						class="rder_item_btn btn-green" style="color: #FFFFFF;">
						<text>一键拨打</text>
					</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import api from '../../api';
	export default {
		data() {
			return {
				scheduleDetailId: '',
				orderList: [],
			}
		},
		
		onLoad(option) {
			this.scheduleDetailId = option.scheduleDetailId
			this.queryByDetailId()
		},
		
		methods: {
			toTel(tel){
				uni.makePhoneCall({
				    phoneNumber: tel //仅为示例
				});
			},
			async queryByDetailId() {
				uni.showLoading({
					title: '加载中'
				});
				const {code, data = []} = await api.order.queryByDetailId({scheduleDetailId: this.scheduleDetailId});
				if(code === 200) {
					this.orderList = data
				}
				uni.hideLoading();
			},
			cancel(orderDetailId) {
				uni.showModal({
					content:'确定上车？',
					success: (res) => {
						if (res.confirm) {
							uni.showLoading({
								title:'验票中...'
							})
							api.order.isCheck({orderDetailId}).then(res=>{
								if(res.code ==200){
									uni.hideLoading()
									uni.showToast({
										title: '上车成功'
									})
									this.queryByDetailId(this.scheduleDetailId)
								}
								else{
									uni.hideLoading()
									uni.showToast({
										title: res.msg
									})
								}
							})
						}
						
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.background {
		height: 100%;
		background: #F7F7F7;
		.order_item {
			background: #FFFFFF;
			border-radius: 16upx;
			padding: 20upx;
			margin: 20upx;
			.order_item_head {
				height: 80upx;
				display: flex;
				flex-direction: row;
				align-items: center;
				justify-content: space-between;
				border-bottom: solid 1upx #EFEFEF;
				.order_time {
					display: flex;
					flex-direction: row;
					align-items: center;
					justify-content: center;
					font-size: 28rpx;
					font-weight: 200;
					line-height: 30upx;
					color: #949699;
					image {
						width: 30upx;
						height: 30upx;
						margin-right: 10upx;
					}
				}
				text {
					font-size: 30rpx;
					color: #949699;
					font-weight: bold;
				}
			}
			.order_info {
				.order_info_item {
					display: flex;
					flex-direction: row;
					align-items: center;
					height: 75upx;
					
					.iconRouter{
						width: 26px;
						height: 26px;
						margin: 0 10upx;
					}
					
					.site_sign {
						width: 20upx;
						height: 20upx;
						border-radius: 50%;
					}
				}
				
			}
		}
	}
	
	.order_item_btn_warp{
		display: flex;
		justify-content: flex-end;
		border-top: 1px solid #EEEEEE;
		padding-top: 20upx;
		margin-top: 20upx;
		
		.rder_item_btn {
			width: 180upx;
			height: 70upx;
			background: #FF8103;
			border-radius: 16upx;
			border: 1px solid #FF8103;
			line-height: 70upx;
			font-size: 34rpx;
			text-align: center;
			margin-left: 10upx;
		}
		
		.btn-green{
			background-color: #009dff;
			border: 1px solid #009dff;
		}
	}
</style>
